<?php
require_once (APPLICATION_DIR."/application/model/Partner.php");
class Partner extends DataObjects_Partner 
{	
	function addPartner($partner_title,$partner_order)
	{
	    $this->partner_title = $partner_title;
	    $this->partner_order = $partner_order;
	    $this->partner_intro = $partner_intro;
	    $this->insert();
	}
	
	function updatePartner($partner_id,$partner_title,$partner_order, $partner_intro)
	{
	    $this->partner_id = $partner_id;
	    $this->partner_title = $partner_title;
	    $this->partner_order = $partner_order;	    
	    $this->partner_intro = $partner_intro;
	    $this->update();
	}
	
	function getAllPartner()
	{
	    $this->selectAdd();
	    $this->selectAdd("*");
	    $this->find();
	    return $this;
	}
	
	function deletePartner($partner_id)
	{
	    $programme = new Programme();
	    $pro = $programme->getAllAdmissionOfPartner($partner_id);
	    if ($pro->fetch())
	    {
	        return "You must delete all admission page of this program first";
	    }
	    else 
	    {
    	    $this->partner_id = $partner_id;
    	    $this->delete();
    	    return "OK";
	    }
	}
	
	function getPartnerByID($partner_id)
	{
	    $this->partner_id = $partner_id;
	    $this->find();
	    return $this;
	}
	
	function prepareDropMenu()
	{
	    $smarty		= DRX::load("smarty");
	    $allpartner	= $this->getAllPartner();
	    $partner_list = $allpartner->fetchList();
	    if (count($partner_list))
	    {
	        $smarty->assign("partner_list",$partner_list);
	        $drop_content = $smarty->fetch("admission/dropmenu.tpl");
	        $admission_id = ADMISSION_ID;
	        $smarty->assign("dropmenu$admission_id",$drop_content);
	    }
	}
}
?>